﻿<!--
// Copyright (c) Trevor Webster
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
                    xmlns:primitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
                    xmlns:my="clr-namespace:DataGridThemes"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/DataGridThemes;component/WhistlerBlue_brushes.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!--ColumnHeader-->
    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}"
                    Background="{TemplateBinding Background}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key='ColumnHeaderStyle' TargetType='{x:Type primitives:DataGridColumnHeader}'>
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <!--<Setter Property="FontSize" Value="10.5" />-->
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Padding" Value="4,6,5,6"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="SeparatorBrush" Value="#FFC9CACA" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type primitives:DataGridColumnHeader}">
                    <Grid>
                        <toolkit:DataGridHeaderBorder x:Name='HeaderBorder' 
                                                  SortDirection="{TemplateBinding SortDirection}"
                                                  IsHovered="{TemplateBinding IsMouseOver}"
                                                  IsPressed="{TemplateBinding IsPressed}"
                                                  IsClickable="{TemplateBinding CanUserSort}"
                                                  BorderBrush="{StaticResource HeaderSeparator}"
                                                  Background='{StaticResource grayGradient}'
                                                  BorderThickness="0,0,1,1"

                                                  SeparatorVisibility="{TemplateBinding SeparatorVisibility}"
                                                  SeparatorBrush="{StaticResource HeaderSeparator}">
                            <Grid Background='Transparent' >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width='Auto' />
                                    <ColumnDefinition Width='*' />
                                </Grid.ColumnDefinitions>
                                <Rectangle x:Name="BackgroundRectangle" Grid.ColumnSpan="2" Grid.RowSpan="2" 
                                   Fill="{StaticResource grayGradient}" Opacity="1"
                                   Stretch="Fill" 
                                   />
                                <Rectangle x:Name="HoverRectangle" 
                                   Grid.ColumnSpan="2" Grid.RowSpan="2" Stretch="Fill" 
                                   Fill="{StaticResource BtnOverFill}" 
                                   Opacity="0" />
                                <Rectangle x:Name="ShineRectangle" 
                                   Fill="{StaticResource hoverGradient}" 
                                   Stretch="Fill" 
                                   Stroke="{StaticResource selectedStroke}" 
                                   Opacity="0"
                                   Grid.ColumnSpan="2" Grid.RowSpan="2"                                   
                                           />
                                <ContentPresenter Grid.Column='0' 
                                                  Grid.ColumnSpan="2"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin='{TemplateBinding Padding}'
                                                  Cursor="{TemplateBinding Cursor}"
                                                  />
                                <Path   x:Name="SortArrow" Margin="0,2,0,0" Height="4" Width="7" 
                                        Grid.ColumnSpan="2"
                                        HorizontalAlignment="Center"
                                        Fill="{StaticResource sortArrow}" 
                                        Stretch="Uniform" Opacity="0" 
                                        Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z "                                         
                                        RenderTransformOrigin="0.5,0.5"
                                        VerticalAlignment="Top" 
                                        >
                                    <Path.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform/>
                                            <SkewTransform/>
                                            <RotateTransform/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>                               
                            </Grid>
                        </toolkit:DataGridHeaderBorder>
                        <Thumb x:Name="PART_LeftHeaderGripper"
                   HorizontalAlignment="Left"
                   Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper"
                   HorizontalAlignment="Right"
                   Style="{StaticResource ColumnHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Opacity" Value="1" />
                            <Setter TargetName="SortArrow" Property="RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="180" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ShineRectangle" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Opacity" Value="1" />
                            <Setter TargetName="ShineRectangle" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property='IsMouseOver' Value='True'>
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="00:00:00" 
                                                         Duration="00:00:00.20000"
                                                         Storyboard.TargetName="HoverRectangle" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                         To='1.0'                                                         
                                                         />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="00:00:00" 
                                                         Duration="00:00:00.20000"
                                                         Storyboard.TargetName="HoverRectangle" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                         To='0'                                                         
                                                         />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>


    </Style>

    <!--Cell-->
    <Style x:Key='CellStyle' TargetType="{x:Type toolkit:DataGridCell}" >
        <Setter Property="Foreground" Value="{StaticResource ThemeForegroundBrush}" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Cursor" Value="Arrow" />
        <Setter Property="BorderThickness" Value="1" />
        <!--Padding hack-->
        <Setter Property="Padding" Value="2 5 2 5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type toolkit:DataGridCell}">
                    <Grid x:Name="Root" Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>                     
                        <Rectangle x:Name="FocusVisual" Margin="0,-2,0,0" 
                                   Stroke="#FF000000" Fill="#FFFFFFFF" 
                                   Opacity="0" IsHitTestVisible="false"/>                        
                        <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Cursor="{TemplateBinding Cursor}"/>
                        <Rectangle x:Name="RightGridLine" VerticalAlignment="Stretch" Width="1" Grid.Column="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property='Opacity' TargetName='FocusVisual' Value='0.8' />
                            <Setter Property="BorderThickness" Value="1" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="IsSelected" 
                Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=toolkit:DataGridRow}, Path=IsSelected, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                />
    </Style>

    <!-- DataGridRow -->
    <Style x:Key='RowStyle' TargetType="{x:Type toolkit:DataGridRow}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type toolkit:DataGridRow}">
                    <Border x:Name="DGR_Border"
                  Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  SnapsToDevicePixels="True">
                        <primitives:SelectiveScrollingGrid>                           
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height='Auto' />
                            </Grid.RowDefinitions>                            
                            <Rectangle x:Name="Selected" Margin="0" Grid.RowSpan="2" Grid.ColumnSpan="2" 
                                   Fill="{StaticResource BtnOverFill}" Stroke="{StaticResource selectedStroke}" 
                                   Opacity="0"/>
                            <Rectangle x:Name="SelectedHighlight" Margin="1" Grid.RowSpan="2" Grid.ColumnSpan="2" 
                                   Stroke="#A0FFFFFF" 
                                   Opacity="0"/>
                            <primitives:DataGridRowHeader Grid.RowSpan="2"
                                                        primitives:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"                                       
                                                        Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type toolkit:DataGrid}}, 
                                Path=HeadersVisibility, 
                                Converter={x:Static toolkit:DataGrid.HeadersVisibilityConverter},
                                ConverterParameter={x:Static toolkit:DataGridHeadersVisibility.Row}}"/>
                            <Rectangle x:Name="Over" Margin="0" Grid.RowSpan="2" Grid.ColumnSpan="2" 
                                   Fill="{StaticResource hoverGradient}" 
                                   Stroke="{StaticResource hoverStroke}" 
                                   Opacity="0"/>
                            <primitives:DataGridCellsPresenter Grid.Column="1"
                                            ItemsPanel="{TemplateBinding ItemsPanel}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            <primitives:DataGridDetailsPresenter Grid.Column="1" Grid.Row="1"
                                                               x:Name='DetailsPresenter' 
                                                               primitives:SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding RelativeSource={RelativeSource AncestorType={x:Type toolkit:DataGrid}}, Path=AreRowDetailsFrozen, Converter={x:Static toolkit:DataGrid.RowDetailsScrollingConverter}, ConverterParameter={x:Static toolkit:SelectiveScrollingOrientation.Vertical}}"                                                                                                                         
                                                               Visibility="{TemplateBinding DetailsVisibility}"                                                               
                                                               />
                            <Rectangle Height="1" HorizontalAlignment="Stretch" 
                                       x:Name="BottomGridLine" 
                                       Fill="{StaticResource HorizontalVerticalGridLinesBrush}" 
                                       Grid.Column="1" Grid.Row="2" />
                        </primitives:SelectiveScrollingGrid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property='IsSelected' Value='True'>
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Selected" Storyboard.TargetProperty="Opacity" To="0.84"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedHighlight" Storyboard.TargetProperty="Opacity" To="1"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Selected" Storyboard.TargetProperty="Opacity" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedHighlight" Storyboard.TargetProperty="Opacity" To="0"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <!--<Setter Property="DetailsVisibility" Value="Visible" />-->
                        </Trigger>                        
                        <MultiTrigger >
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Over" Storyboard.TargetProperty="Opacity" To="0.73"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>    
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Over" Storyboard.TargetProperty="Opacity" To="0"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsFocused" Value="False" />                               
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Selected" Storyboard.TargetProperty="Opacity" To="0.84"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedHighlight" Storyboard.TargetProperty="Opacity" To="1"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Selected" Storyboard.TargetProperty="Opacity" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedHighlight" Storyboard.TargetProperty="Opacity" To="0"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--DataGrid -->
    <Style TargetType='{x:Type toolkit:DataGrid}'>
        <Setter Property='ScrollViewer.CanContentScroll' Value='False' />
        <Setter Property='AutoGenerateColumns' Value='False' />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="RowBackground" Value="#FFFFFFFF"/>
        <Setter Property="Background" Value="#FFFFFFFF"/>
        <Setter Property="AlternatingRowBackground" Value="#FFFFFFFF"/>
        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource HorizontalVerticalGridLinesBrush}"/>
        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource HorizontalVerticalGridLinesBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource GridBorder}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property='GridLinesVisibility' Value='All' />      
        <Setter Property='SelectionUnit' Value='CellOrRowHeader' />
        <Setter Property='SelectionMode' Value='Single' />
        <Setter Property='IsReadOnly' Value='False' />        
        <Setter Property='CanUserAddRows' Value='True' />
        <Setter Property='CanUserSortColumns' Value='True' />
        <Setter Property='CanUserResizeRows' Value='False' />
        <Setter Property='CanUserSortColumns' Value='True' />
        <Setter Property='IsSynchronizedWithCurrentItem' Value='True'/>
        <Setter Property="EnableRowVirtualization" Value="True" />
        <Setter Property='CellStyle' Value='{StaticResource CellStyle}' />
        <Setter Property='RowStyle' Value='{StaticResource RowStyle}' />        
        <Setter Property='RowDetailsVisibilityMode' Value='VisibleWhenSelected' />
        <Setter Property='ColumnHeaderStyle' Value='{StaticResource ColumnHeaderStyle}' />
        <Setter Property='VerticalAlignment' Value='Center' />
        <Setter Property='FontFamily' Value='Verdana' />
        <!--FontSize hack-->
        <Setter Property='FontSize' Value='11' />
    </Style>
</ResourceDictionary>